#ifndef WIDGET_H
#define WIDGET_H


#include <QWidget>
#include <QDebug>
#include <QString>
#include <string>
#include <QFile>
#include <QTextStream>
#include <iostream>
#include <windows.h>
#include <QMenu>
#include <QPixmap>
#include <QPushButton>
#include <QScreen>
#include <QApplication>
#include <QDir>
#include <QFileDialog>
#include <QMessageBox>
#include <QLabel>
#include <QWindow>
#include <QTextEdit>
#include <QRegExpValidator>
#include <QSettings>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QJsonParseError>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QClipboard>
#include <QBuffer>
#include "screenwidget.h"

#define _hypot hypot
#include <cmath>

QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);

    QMenu *menu = new QMenu(this);
    //取得屏幕大小
    QScreen *screen = QGuiApplication::primaryScreen();
    //保存全屏图像

    //QPixmap* fullScreen = new QPixmap();
    QPushButton* btn = new QPushButton(this);   //截图
    QPushButton* btn1 = new QPushButton(this);  //测试+获取令牌
    QPushButton* btn2 = new QPushButton(this);  //截图
    QPushButton* btn3 = new QPushButton(this);  //识别
    QPushButton* btn4 = new QPushButton(this);  //保存
    QPushButton* btn5 = new QPushButton(this);  //是否扑捉套装
    QPushButton* btn6 = new QPushButton(this);  //强化识图
    QPushButton* btn7 = new QPushButton(this);  //强化识图2,结果
    QLabel* lable = new QLabel(this);
    QTextEdit* text = new QTextEdit(this);
    int btnFlag = 0;

    //QString accessToken = "24.cecc5302c9bf36cac2e2d04a778164c6.2592000.1648474599.282335-24068540";
    QString accessToken;
    QNetworkAccessManager *nam;
    QString imageStr = "";
    QJsonObject textObj;
    QJsonArray jsonArr;
    int wordsNum = 0;

    //声明窗口ID
    unsigned long  ID = 0;

    //void distinguish();     //python相关的   //废弃
    void distinguishC();     //distinguish函数的新版
    void getWindowsXY();    //似乎不需要使用了
    void getImage();        //截取部分图片
    void getImage2();        //截取部分图片
    void appText();
    void appTextQ();
    void appTextO();
    QString appToText(QString data);
    QString appToTextQ(QString key,QString value);
    QString appToTextO(QString key,QString value1,QString value2);
    bool isTao = false;     //是否为套装
    bool isQTao = true;     //是否记录套装
    bool isStart = false;   //是否开启记录
    void saveTxt();
    //void getAcc();        //废弃
    void getAccC();         //getAcc函数的新版

    void TEST();
    void iniAcc();

    void paintEvent(QPaintEvent *event);

    ~Widget();

private slots:
    void recognitionRequestFinished(QNetworkReply* reply);
    void getAccessTokenRequestFinished(QNetworkReply* reply);
private:
    Ui::Widget *ui;
};
#endif // WIDGET_H
